<extend name="Public/base"/>

<block name="body">
    <div class="main-title">
        <h2><if condition="ACTION_NAME eq 'add'">新建<else/>分配</if>预约单</h2>
    </div>
    <form action="{:U()}" id="commentForm" method="post"  class="form-horizontal" >
    <!-- 判断插入ID是否为空，如不为空隐藏插入ID值 -->
        <notempty name="data['id']">
            <input type="hidden" name="id" value="{$data['id']}"/>
        </notempty>

        <div class="form-item">
            <label class="item-label">顾客姓名<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="name" value="{$data.name}" disabled="false">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">顾客手机号码<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="phone" value="{$data.phone}" disabled="false">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">顾客微信<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="qq" value="{$data.qq}" disabled="false">
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">预约日期<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" placeholder="请输入日期" class="text input-large laydate-icon" onclick="laydate()" name="yytime" <if condition="ACTION_NAME eq 'add'"> value="" <else/>value="{$data.yytime|date="Y-m-d",###}"</if> style="padding-right: 3px;" disabled="false">
        </div>
        <div class="form-item">
            <label class="item-label">顾客倾向套系<span class="check-tips">（请填写顾客倾向或备注）</span></label>
            <div class="controls">
                <textarea  class="text input-large" style="height: 100px;" name="bz" value="{$data.bz}" disabled="false">{$data.bz}</textarea>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">获取客服<span class="check-tips"></span></label>
            <div class="controls">
                <select name="kf" disabled="false">
                            <php>if(count($kefu) !== 1){echo "<option value=''>未分配客服</option>";}</php>
                      <volist name="kefu" id="vo">
                            <option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.kf"> selected</eq>>{$vo.nickname|default=null}</option>
                      </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">渠道<span class="check-tips"></span></label>
            <div class="controls">
                <select name="qd" disabled="false">
                      <volist name="qudao" id="vo">     
                            <option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.qd"> selected</eq>>{$vo.name|default=null}</option>
                      </volist>
                </select>
            </div>
        </div>
        <div class="form-item">
            <label class="item-label">业务类别<span class="check-tips"></span></label>
            <div class="controls">
                <select name="lb" disabled="false">
                    <volist name="liebei" id="vo">
                        <option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.lb"> selected</eq>>{$vo.name|default=null}</option>
                    </volist>
                </select>
            </div>
        </div>    
        <neq name="quanxian" value="4">
            <div class="form-item">
                <label class="item-label">线上门市<span class="check-tips">(选择“线上门市”后系统会发送微信通知信息到指定门市）</span></label>
                <div class="controls">
                      <select name="xsjd" <php> if($quanxian !== 6){echo 'disabled="false"';} </php>>
                            <option value=''>未分配门市</option>
                            <volist name="xianshang" id="vo">
                                <option value="{$vo.uid|default=null}" <php>if($vo['uid'] === $data['xsjd']){echo "selected";
                                }</php> >{$vo.nickname|default=null}</option>                          
                            </volist>
                      </select>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">线下门市<span class="check-tips"></span></label>
                <div class="controls">
                      <select name="xxjd" >
                            <option value=''>未分配门市</option>
                            <volist name="xianxia" id="vo">
                                <option value="{$vo.uid|default=null}" <php>if($vo['uid'] === $data['xxjd']){echo "selected";
                                }</php> >{$vo.nickname|default=null}</option>                          
                            </volist>
                      </select>
                </div>
            </div>
            <div class="form-item">
                <label class="item-label">订单金额<span class="check-tips"></span></label>
                <div class="controls">
                    <input type="text" class="text input-large" name="money" value="{$data.money}" disabled="false">
                </div>
            </div>
        </neq>
        <div class="form-item">
            <label class="item-label">订单状态<span class="check-tips">(选择“确认意向”后系统会发送微信通知信息到下线门市经理）</span></label>
            <div class="controls">
                <select name="ywstate" disabled="false">
                    <volist name="state" id="vo">
                        <option value="{$vo.uid|default=null}" <eq name="vo.uid" value="$data.ywstate"> selected</eq>>{$vo.name|default=null}</option>
                    </volist>
                </select>
            </div>
        </div>    
        <div class="form-item">
            <label class="item-label">推荐人<span class="check-tips"></span></label>
            <div class="controls">
                <input type="text" class="text input-large" name="tj" value="{$data.tj}" disabled="false">
            </div>
        </div>   

        <div class="form-item">
            <button class="btn submit-btn" id="submit" type="submit" target-form="form-horizontal">确 定</button>
            <button class="btn btn-return" onclick="javascript:history.back(-1);return false;">返 回</button>
        </div>
    </form>

</block>

<block name="script">
    <script src="__STATIC__/thinkbox/jquery.validate.js"></script>
    <script src="__STATIC__/thinkbox/jquery.metadata.js"></script>
    <script src="__STATIC__/thinkbox/laydate.js"></script>
    <script >

    $().ready(function() {
         $("#commentForm").validate({

          rules: {
           name: { required:true
           },
           phone: {
            isMobile : true
           },
           yytime:{
            required: true,
            dateISO:true
           }
          },
           messages: {
               name: "请输入姓名！",
               phone: {
                required: "请输入手机号码！",
                isMobile: "请输入正确的手机号码！"
               },
               yytime:{
                required:"请填写预约时间！",
                dateISO:"请填写正确预约时间！"
               }
            },
            submitHandler : function(form){

            $.ajax({
                type: "POST",
               <if condition="ACTION_NAME eq 'add'">url: "{:U('add')}",<else/>url: "{:U('edit')}",</if> 
                data: $(form).serialize(),
                success: function(msg){
                    $('.alert-content').html(msg.info);
                    $('#top-alert').addClass('alert-success').show();
                    setTimeout(function(){
                        location.href=msg.url;
                    },2500); //延迟演示
                },
            });
            $('#submit').attr("disabled","false");
            }

         });

          return false;   
        });
    </script>
    <script type="text/javascript">
        //导航高亮
        highlight_subnav('{:U('Ywxt/index')}');
    </script>
</block>
